<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Number Tests</title>
<script type="text/javascript" src="../../../../build/yui/yui.js"></script>
</head>

<body class="yui3-skin-sam">
<h1>Number Performance Tests</h1>
<p><select id="testSelector"></select> <input type="button" value="Run Test" id="btnRun" disabled=true></p>

<script type="text/javascript">
(function() {
    YUI({
        base: "../../../../build/",
        filter: "debug",
        logInclude:{"perf":true, "number":true},
        useConsole: true
    }).use("console", "datatype-number", function(Y) {

        // Set up the page
        var BTNRUN = Y.one("#btnRun"),
            myConsole = new Y.Console().render();


        BTNRUN.set("disabled", false);
        Y.on("click", function(e){
            Y.example.Perf.run();
        }, BTNRUN);

        Y.namespace("example").Perf = function() {
            var selectNode = Y.one("#testSelector"),
                allTests = [];

            return {
                init: function() {
                    this.register("Test number parsing", function() {
                        var i = -250,
                            max = 250,
                            j=0,
                            number, string;

                        for(; i<max; i++) {
                            number = Y.Number.parse(i+"");
                            string = Y.Number.format(number,
                                {prefix:"pre",decimalPlaces:2,decimalSeparator:",",thousandsSeparator:".",suffix:"post"});
                        }
                    });

                },

                register: function(testName, testFn) {
                    var index = allTests.length;
                    allTests[index] = testFn;

                    var optionEl = document.createElement("option");
                    optionEl.innerHTML = "Test " + index + ": " + testName;
                    selectNode.appendChild(optionEl);
                },

                run: function() {
                    var whichTest = selectNode.get("selectedIndex");
                    Y.log("Starting Test " + whichTest, "info", "perf");
                    allTests[whichTest].apply(this);
                    Y.log("Test " + whichTest + " completed", "info", "perf");
                }
            }
        }();

        Y.example.Perf.init();
    });
})();
</script>
</body>
</html>
